﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XCommunity.Documents;

namespace XCommunity.Frames
{

  /// <summary>
  /// 代表一个已经被发布的文档
  /// </summary>
  public class PublishedDocument
  {


    private FrameService _frameService;
    private DocumentService _documentService;

    internal PublishedDocument( ITopicFrame topic, int documentId, DocumentService documentService, DateTime publishedDate, string method )
    {
      _topicId = topic.TopicId;
      _frameService = topic.Service;

      _documentId = documentId;
      _documentService = documentService;

      _publishDate = publishedDate;
      _method = method;
    }


    private int _topicId;

    public int TopicId
    {
      get { return _topicId; }
    }

    public ITopicFrame GetTopic()
    {
      return _frameService.GetTopicFrame( _topicId );
    }



    private int _documentId;

    public int DocumentId
    {
      get { return _documentId; }
    }

    public Document GetDocument()
    {
      return _documentService.GetDocument( _documentId );
    }


    private DateTime _publishDate;

    public DateTime PublishDate
    {
      get { return _publishDate; }
    }


    private string _method;

    public string PublishMethod
    {
      get { return _method; }
    }



    public static implicit operator Document( PublishedDocument publishedDocument )
    {
      return publishedDocument.GetDocument();
    }
  }
}
